home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / A86V402.ZIP / A03.DOC < prev    next >
Text File  |  1994-12-17  |  23KB  |  508 lines

  1. CHAPTER 3   OPERATION AND REQUIREMENTS
  2.  
  3.  
  4. Creating Programs to Assemble
  5.  
  6. Everything I say about A86 applies equally well to my A386
  7. assembler, whose program name is A386.  The additional features
  8. of A386 consist of the 32-bit register set and additional
  9. instructions and instruction forms, outlined in Chapter 6.  A386
  10. is available only on the registered A86+D86 disk.
  11.  
  12. Before you invoke A86 you must have an assembly-language source
  13. program to assemble.  A source program is an ASCII text file,
  14. created with the text editor of your choice.  The editor must
  15. produce a file that is free of internal records known only to the
  16. editor.  Some of the fancier word processors will require you to
  17. use a "plain text" mode to insure that the file is free of such
  18. records.
  19.  
  20. This manual will fully explain to you the correct syntax of an
  21. A86 program, but it is not intended to teach you about the
  22. 86-family instruction set, or about assembly-language interfacing
  23. to your computer or your operating system.
  24.  
  25. The instruction set charts in Chapters 6 and 7 give concise,
  26. one-line descriptions of each instruction, but they don't go into
  27. any detail about instruction usage, or about how to make system
  28. calls to input from keyboard or disk, output to screen, printer
  29. or disk, etc.  For that, you need a book that covers the MS-DOS
  30. operating system and the BIOS for the IBM-PC.  I am currently
  31. using DOS Programmer's Reference by Terry Dettmann, available by
  32. mail from Public Brand Software at 1-800-426-3475.  At a more
  33. instructional level, my users report that Peter Norton's Assembly
  34. Language Guide to the IBM-PC has been helpful.
  35.  
  36.  
  37. Program Invocation
  38.  
  39. To invoke A86, you must provide a program invocation line, either
  40. typed to the console when the DOS command prompt appears, or
  41. included in a batch file.  The program invocation line consists
  42. of the program name A86, followed by assembler switches
  43. (described in the next section), and the names of the source
  44. files you want to assemble, and of the output files you want to
  45. produce.  If the output files all have their standard extensions,
  46. they may appear in any order: before, after, or even intermixed
  47. with the source file names.  If they don't have their standard
  48. extensions, you must give the source file names first, followed
  49. by the word TO, followed by the output file names.  Each
  50. non-standard name following the word TO will be assigned to the
  51. first previously- unassigned output file in order: program,
  52. symbols, listing, then cross-reference.
  53.  
  54. You may use the wild card delimiters * and ? if you wish, to
  55. denote a group of source files to be assembled.  A86 will sort
  56. all matching names into alphabetical order for each wild card
  57. specification; so the files will be assembled in the same order
  58. even if they get jumbled up within a directory.
  59.                                                               3-2
  60.  
  61. If you provide a name without a period or an extension, A86 will
  62. use that as the output program file name, appending to it the
  63. default extension as follows:
  64.  
  65. 1. .OBJ if you invoked the +O switch, for linkable object file
  66.    production.
  67.  
  68. 2. .BIN if there is no +O switch, but there is an ORG 0 of in
  69.    your program, without a later ORG 256.
  70.  
  71. 3. .COM otherwise.
  72.  
  73. If you want your program file to have no extension, you end the
  74. file name with a period.
  75.  
  76. You may omit any of the output file names if you wish.  If you do
  77. so, A86 will output the program source.COM (or source.OBJ or
  78. source.BIN), where "source" is a name derived from the list of
  79. source files, according to the rules described in the section
  80. "Strategies for Source File Maintenance" later in this chapter.
  81. Any of the other output files will use the name of the program
  82. output file, combined with the standard extension for that output
  83. file.
  84.  
  85.  
  86. Assembler Switches
  87.  
  88. In addition to input and output file names, you may intersperse
  89. assembler switch settings anywhere after the A86 program name.
  90. They are all acted upon immediately, no matter where they are on
  91. the command line.  Some of the switches are discussed in more
  92. detail elsewhere; I'll summarize them here:
  93.  
  94. +C     causes the assembler to output symbol names with lower
  95.     case letters to its OBJ and SYM files.  The case of letters
  96.     is still ignored during assembly.  I output the name as it
  97.     appears in the last PUBLIC or EXTRN directive containing it;
  98.     if there is no such directive, I use the first occurrence of
  99.     the symbol to control which letters are output lower case.
  100.     (+C duplicates Microsoft MASM's /mx switch.)
  101.  
  102. +c     causes the assembler to consider the case of letters
  103.     within all non-built-in symbols as significant both during
  104.     assembly and for output.  Thus, for example, you can define
  105.     different symbols X and x.  (+c duplicates MASM's /ml
  106.     switch.)
  107.  
  108. +D     causes the default base for numeric constants to be
  109.     decimal, even if the constants have leading zeroes.
  110.  
  111. -D     causes the default base to be hexadecimal if there is a
  112.     leading zero; decimal otherwise.
  113.  
  114. +E     causes the error-message-augmented source file to be
  115.     written to yourname.ERR within the current directory, in all
  116.     cases. With +E, A86 will never rewrite your original source
  117.     file.
  118.                                                               3-3
  119.  
  120. -E     causes A86 to insert error messages into your source file,
  121.     whenever the file is in the current directory.  If the file
  122.     is not in the current directory, A86 writes an ERR file no
  123.     matter what the E switch setting is.
  124.  
  125. +F     causes A86 to generate the 287 form of floating point
  126.     instructions (no implicit FWAIT bytes are generated before
  127.     the instructions).  This mode can also be specified in the
  128.     program with the .287 directive.
  129.  
  130. +f     causes A86 to support emulation of the 8087.  When A86
  131.     sees a floating point instruction, it generates external
  132.     references to be resolved by the standard emulation library
  133.     (provided by Microsoft, Borland, etc.).  When you LINK your
  134.     program to the emulation library, the floating point
  135.     instructions are emulated by software.  NOTE you must be
  136.     assembling to a linkable OBJ file for this mode to have
  137.     effect; otherwise, +f is ignored.
  138.  
  139. -F     causes emulation and default-287 to be disabled.  You'll
  140.     still get 287 generation if there is a .287 directive in your
  141.     program.
  142.  
  143. +G  n         causes A86 to implement one or more of the
  144.     following minor options for code-generation.  All these
  145.     options enhance MASM compatibility.  The first three do so at
  146.     the expense of program size.  The number n should be the sum
  147.     of the numbers for each of the options selected.  For
  148.     example, +G10 will select the options numbered 2 and 8.
  149.  
  150.     1    causes A86 to generate a longer (3-byte) instruction
  151.         form for an unconditional JMP instruction to a forward
  152.         reference local label, e.g. JMP >L1.  A86 normally
  153.         assumes that since it's a local label, it will be nearby
  154.         and the short, 2-byte form will work.  With this option
  155.         your code will usually be longer than necessary, but
  156.         you'll be spared having to occasionally go back and code
  157.         an explicit JMP LONG >L1.
  158.  
  159.     2    causes A86 to refrain from optimizing the LEA
  160.         instruction. Without this option A86 will replace an LEA
  161.         with a shorter, equivalent MOV when it sees the chance.
  162.  
  163.     4    causes A86 to generate a slightly more inefficient
  164.         internal format for memory references within an OBJ file.
  165.         The Power C compiler's MIX utility requires the
  166.         inefficient form. The makers of Power C refused to
  167.         support their customers on this by enhancing MIX, so I am
  168.         forced to offer this option.
  169.  
  170.     8    causes A86 to assume that all ambiguous forward
  171.         reference operands to instructions other than jumps or
  172.         calls refer to memory variables and not offsets or
  173.         constant values.  You can override this on a one-by-one
  174.         basis, with the OFFSET operator.
  175.                                                               3-4
  176.  
  177.     16   causes A86 to require that undefined names be explicitly
  178.         declared with an EXTRN when A86 is producing a linkable
  179.         .OBJ file.  This switch has no effect when A86 is making
  180.         a .COM file.  Without the switch, A86 will, when
  181.         assembling to an .OBJ file, quietly assume that all
  182.         undefined names are valid external references.
  183.  
  184. -G      causes A86 to revert to its default for all the above
  185. options.
  186.  
  187. +H  n      causes A86 to produce n extra listing lines, as
  188.     necessary, containing excess hex bytes of object code
  189.     produced by each source line.  Without this switch, A86
  190.     produces extra hex lines only if it producing extra lines
  191.     anyway to display excess source code.
  192.  
  193. +I  n       controls the indentation of the source line within an
  194.     A86 listing line (and thus the amount of room allocated for
  195.     the hex object display).  You may have any indentation up to
  196.     127.  The default value is 34, which gives room for 6 hex
  197.     object bytes.  You may add or subtract 3 to that value, to
  198.     increase or decrease the hex object bytes.  If you add 128 to
  199.     the value of n, the listing of the line number is suppressed
  200.     (so you can subtract 6 from the indentation to get the same
  201.     number of hex digits).
  202.  
  203. +L  n       causes A86 to produce a listing file of the assembly.
  204.     The n is optional, and controls what will be included in the
  205.     listing.  You add numbers from the following table to produce
  206.     an n which specifies the combination of elements you want:
  207.  
  208.     Use at most one of the following three values:
  209.  
  210.          * Use 1 if you want A86 to eliminate all conditional
  211.             assembly control lines (#IF, #ENDIF, etc.) and all
  212.             conditionally skipped code from the listing.
  213.  
  214.          * Use 2 if you want A86 to include the control lines but
  215.             not the skipped code.
  216.  
  217.          * Use 3 if you want A86 to include both control lines
  218.             and skipped code.
  219.  
  220.     4   causes A86 to include the lines produced by macro
  221.        expansions.  Otherwise, only the macro call line is
  222.        listed.
  223.  
  224.     8   causes listing control lines (TITLE, SUBTTL, PAGE) to be
  225.        listed.
  226.  
  227.     16  causes the hex output object pointer to be included on
  228.        all listing lines, whether they have produced hex object
  229.        bytes or not.  Otherwise, the 4-digit pointer is included
  230.        only on lines producing object bytes; on other lines, the
  231.        field is blank (but the line itself is listed!).
  232.                                                               3-5
  233.  
  234.     32  causes a symbol-table listing to be produced at the end
  235.        of the listing file.
  236.  
  237.     If n is not given after +L, a value of 39 is assumed: symbol
  238.     table, hex pointer only if there are object bytes, no listing
  239.     control lines, and macro expansion lines, conditional control
  240.     lines, and skipped lines are all listed.  If +L is not given
  241.     at all, then a listing file will be produced only if it is
  242.     explicitly named on the invocation line.
  243.  
  244. +O     causes A86 to produce a linkable .OBJ file when the output
  245.     file name extension is not explicitly given.
  246.  
  247. -O     causes A86 to produce an executable .COM file when the
  248.     output file name extension is not explicitly given.
  249.  
  250. +P  n      controls which processor A86 is assembling for.  You
  251.     choose one of the following values for n, for the level of
  252.     Intel processor support you wish:
  253.  
  254.           * Choose 0 for the base 8086/8086 instruction set only.
  255.             Use this value if you want your programs to run on
  256.             all machines.
  257.  
  258.           * Choose 1 for instructions up through the 186.
  259.  
  260.           * Choose 2 for instructions up through the 286.  Use
  261.             this value if you are assembling for a more recent
  262.             processor (386, 486, etc.), until A386 is available.
  263.  
  264.     In addition, you may add the value 32 to n if you wish the
  265.     NEC-specific instructions to be assembled.  Since the NEC
  266.     processor include the 186 instructions, you specify +P33 to
  267.     assemble for a NEC processor; use +P35 if you wish to allow
  268.     all possible instructions (which is what older versions of
  269.     A86 allowed).
  270.  
  271.     The switch setting +P64 specifies assembly of the base-level
  272.     8086/8088 instruction set, but with special handling of a few
  273.     of the later instruction forms, to generate compatible code.
  274.     Specifically: all shift and rotate instructions with an
  275.     immediate shift value greater than 1 will generate that many
  276.     repetitions of the 1-value instruction form; e.g., ROL BL,3
  277.     will generate 3 copies of ROL BL,1.  The mnemonics PUSHA and
  278.     POPA will be honored, generating appropriate sequences of
  279.     multiple PUSHes and POPs.
  280.  
  281.     The default setting for this switch is for A86 to assemble
  282.     for the processor on which it is currently running; +P64 if
  283.     that processor is an 8086 or 8088.
  284.  
  285. +S     suppresses the creation of the symbol table (.SYM) file.
  286.     This is overridden if you give an explicit symbols file name
  287.     in the invocation line.
  288.                                                               3-6
  289.  
  290. +T  n     controls various options conerning the titling and
  291.     pagination of listing files.  You add together your selection
  292.     of options from the following list, to produce a value of n
  293.     containing the combination you want:
  294.  
  295.     The following values control the automatic incrementing of
  296.     section numbers in an A86 listing.  The section number
  297.     appears to the left of the hyphen in a page number.  Use at
  298.     most one of the following three values:
  299.  
  300.           * Use 1 if you want A86 to refrain from incrementing
  301.             the section number whenever there is a change to the
  302.             source file.  If you choose this option, and you
  303.             don't manually increment the section number in a PAGE
  304.             directive, then page numbers will be single numbers
  305.             without any hyphenation.
  306.  
  307.           * Use 2 if you want A86 to increment the section number
  308.             for each new main source file, but not for INCLUDE
  309.             files.
  310.  
  311.           * Use 3 if you want A86 to increment the section number
  312.             for all source files, INCLUDE files, and returns from
  313.             INCLUDE.
  314.  
  315.     4   causes A86 to automatically issue a page break at
  316.        reasonable places in the code (file breaks, and gaps of
  317.        consecutive blank lines of various lengths occurring near
  318.        the end of a page).  This is described in more detail in
  319.        Chapter 13.
  320.  
  321.     8   causes A86 to issue the page-ending formfeed instead of
  322.        the last linefeed, rather than in addition to it.  The
  323.        advantage of this is that you can specify one more line on
  324.        a page for many printers. The disadvantage is that some
  325.        editors and file-viewing programs will not display such a
  326.        file correctly; e.g. LIST will not show the last line of a
  327.        page.
  328.  
  329.     16   causes A86 to use the current source-file name as a
  330.        default TITLE if there has been no TITLE directive in the
  331.        program; as an implicit SUBTTL at the beginning of each
  332.        file if there is a TITLE explicitly given.
  333.  
  334.     32   causes A86 to output a 2-line gap, followed by a line
  335.        containing the name of the source file, every time the
  336.        source file changes in the listing.
  337.  
  338.     If -T (or +T0) is specified, then no titling or pagination is
  339.     done at all.  If the switch is not specified at all, a
  340.     default value of 52 (auto-paging, auto-titling, and source
  341.     file line, but no auto-section and no FF instead of LF).  Of
  342.     course, if there is no listing file the T switch has no
  343.     effect.
  344.                                                               3-7
  345.  
  346. +W   n       controls the characteristics of wide lines in the
  347.     A86 listing file.  You add together your selection of options
  348.     from the following list, to produce a value of n containing
  349.     the combination you want:
  350.  
  351.     0--3    (at most one value!) determines the indentation from
  352.        the beginning of the source line for wrapped-around source
  353.        code on subsequent lines.  The indentation will be 5
  354.        spaces times the number given: 0,5,10,15 spaces
  355.        respectively.
  356.  
  357.     4   causes A86 to truncate lines that exceed the page width.
  358.        Exception: if A86 is outputting a line with trailing hex
  359.        bytes anyway (via the H switch), any wrapped-around source
  360.        will be shown on those lines.
  361.  
  362.     8   causes A86 to start with a listing line width of 79.
  363.        Without this option, the width is 131.  The width can be
  364.        set to other values in the source code via the PAGE
  365.        directive, described in Chapter 13.
  366.  
  367.     16   causes the title lines at the head of the page not to
  368.        exceed 79 bytes in width, even if the other listing lines
  369.        are longer.  This option is handy if you are viewing a
  370.        listing on the screen, with a viewing program that
  371.        truncates long lines: the page headers will still be
  372.        visible during normal scrolling.
  373.  
  374. +X      causes A86 to produce a cross-reference file (the same
  375.     file that was produced by the XREF utility in earlier
  376.     versions of A86).
  377.  
  378. Unless otherwise stated, the default setting for all the switches
  379. is "minus".  Multiple switches can be specified with a single
  380. sign; e.g. +OG15L55 is the same as +O+G15+L55.
  381.  
  382.  
  383.  
  384. The A86 Environment Variable
  385.  
  386. To allow you to customize A86, the assembler examines the MS-DOS
  387. environment variable named "A86" when it is invoked.  If there is
  388. such a variable, its contents are inserted before the invocation
  389. command tail, as if you had typed them yourself.
  390.  
  391. For example, if you execute the command SET A86=+O while in DOS
  392. (typically in the AUTOEXEC.BAT file run when the computer is
  393. started), then the O switch will be "plus", unless overridden
  394. with a "minus" setting in the command line.
  395.                                                               3-8
  396.  
  397. You may also include one or more file names in the A86
  398. environment variable.  Those files will always be assembled
  399. first, before the files you specify on the command line.  This
  400. allows you to set up a library of macro definitions, which will
  401. always be automatically available to your programs.  Thus, for
  402. example, the DOS command  SET A86=C:\A86\MACDEF.8 +O  will cause
  403. both the O switch to default ON, but will also cause the file
  404. MACDEF.8 of subdirectory A86 of drive C to always be assembled.
  405.  
  406.  
  407. Using Standard Input as a Command Tail
  408.  
  409. The following feature is a bit advanced.  If you're not familiar
  410. with the practice of redirecting standard input, you may safely
  411. skip this section.
  412.  
  413. A86 can also be configured to take its command arguments from
  414. standard input, in addition to the invocation command tail or the
  415. A86 environment variable.  This allows A86 to be used in those
  416. menu-driven systems that don't generate command tails for
  417. programs.  It also allows other programs to create lists of files
  418. to be assembled, then "pipe" the list to A86.
  419.  
  420. Here's how the feature works: when the command argument A86 is an
  421. ampersand &, A86 will prompt for standard input.  If the
  422. ampersand is seen but there are other things following it, the
  423. ampersand is ignored.
  424.  
  425. For example, you can place a list of file names and switch
  426. settings into a file called FILELIST.  You can then invoke the
  427. assembler via
  428.  
  429. A86 <FILELIST &
  430.  
  431. which will cause the contents of the FILELIST file to be used as
  432. a command line.
  433.  
  434. You may place an ampersand at the end of your A86 environment
  435. variable.  If you do so, then A86 will prompt for file names
  436. whenever it is invoked without any command arguments (you type
  437. A86 followed immediately by the ENTER key to the MS-DOS prompt).
  438. This is the mode used if you have a menu system that can't
  439. generate an invocation command tail.
  440.  
  441. Note: when you redirect standard input so that it comes from a
  442. file, A86 will read all the lines of the file (up to a limit of
  443. 1023 bytes), and substitute spaces for the line breaks.  Thus you
  444. may give the file names on individual lines, for readability.
  445. However, if the feature is invoked manually (no redirection), so
  446. that you are typing in the line after the prompt, A86 will take
  447. the first line only.  You need to give all your switches and
  448. files on that one line.
  449.                                                               3-9
  450.  
  451. Strategies for Source File Maintenance
  452.  
  453. A86 encourages modular programming, by letting you break your
  454. source into separate files, with complete impunity.  A86 has no
  455. concern whatsoever for file breaks-- it treats the sequence of
  456. files as a single source code stream.
  457.  
  458. You should consider one or more of the following strategies,
  459. which I have adopted in my source file management:
  460.  
  461. 1. I name all my A86 source files with the same extension, which
  462.    is found on no other files. The particular extension I have
  463.    chosen is ".8". I did not choose the more common .ASM, because
  464.    I have a few source files designed for MSDOS's assembler.  If
  465.    you don't like .8, I would suggest .A86.
  466.  
  467. 2. I keep a separate subdirectory on my hard disk for each
  468.    multi-source-file A86 program I have.  Then the simple command
  469.    "A86 *.8" performs the assembly for the current directory's
  470.    program.
  471.  
  472. 3. I exploit the fact that A86 expands wild cards into
  473.    alphabetical order.  Whenever I want a source file to be
  474.    assembled first (e.g., when it contains variable
  475.    declarations), I append a decimal digit to the start of the
  476.    file name: 0 for the first file, 1 for the second, etc., for
  477.    however many files that need to be explicitly ordered.  If a
  478.    file needs to come last, I append a "Z" to the start of the
  479.    file name.
  480.  
  481.    To accommodate this strategy, I have programmed A86 to a
  482.    somewhat complicated algorithm for determining the default
  483.    output file name.  I use the name of the first source file;
  484.    but I truncate the first character if it is a decimal digit.
  485.    However, you may have a general-purpose file that must come
  486.    first; so I have provided the following exception: if you have
  487.    a source file whose name begins with the digit "9", that name
  488.    (without the 9) is used.  If you don't like this, you can
  489.    always explicitly give the program name you want: "A86 *.8
  490.    MYPROG".
  491.  
  492.  
  493. System Requirements for A86
  494.  
  495. A86 requires MS-DOS V2.00 or later.  No BIOS or lower-level calls
  496. are made by A86, so A86 should run on any MS-DOS machine.  Please
  497. let me know if you find this not to be the case.
  498.  
  499. A86 itself is a small program, and it is fairly flexible about
  500. the memory it uses.  You can assemble with only 40K bytes of
  501. memory beyond the program itself, which in the current version is
  502. under 35K bytes-- a total of 75K bytes beyond the operating
  503. system.  There is no longer any limit on the size of source files
  504. assembled under A86.  The more memory you have, the more capacity
  505. A86 has, in symbol table size and output file size.  If it can,
  506. A86 will use up to 400K bytes of memory.
  507.  
  508.